package com.knight.hadoop.day09.joinMR;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Writable;

/**
 * 
 * 组装订单信息和商品信息的model
 *
 */
public class InforBean implements Writable {

	private int orderId;
	private String date;
	private String pid;
	private float amount;
	private String pname;
	private int category_id;
	private float price;
	
	//0表示订单的 1表示商品的
	private String flag;//表示该记录是订单的还是商品的
	
	public InforBean() {}

	public void set(int orderId, String date, String pid, float amount, String pname, int category_id, float price,String flag) {
		this.orderId = orderId;
		this.date = date;
		this.pid = pid;
		this.amount = amount;
		this.pname = pname;
		this.category_id = category_id;
		this.price = price;
		this.flag = flag;
	}


	@Override
	public void write(DataOutput out) throws IOException {
		out.writeInt(orderId);
		out.writeUTF(date);
		out.writeUTF(pid);
		out.writeFloat(amount);
		out.writeUTF(pname);
		out.writeInt(category_id);
		out.writeFloat(price);
		out.writeUTF(flag);
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		orderId = in.readInt();
		date = in.readUTF();
		pid = in.readUTF();
		amount = in.readFloat();
		pname = in.readUTF();
		category_id = in.readInt();
		price = in.readFloat();
		flag = in.readUTF();
	}

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public float getAmount() {
		return amount;
	}

	public void setAmount(float amount) {
		this.amount = amount;
	}

	public String getPname() {
		return pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	public int getCategory_id() {
		return category_id;
	}

	public void setCategory_id(int category_id) {
		this.category_id = category_id;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	@Override
	public String toString() {
		return "orderId=" + orderId + ", date=" + date + ", pid=" + pid + ", amount=" + amount + ", pname="
				+ pname + ", category_id=" + category_id + ", price=" + price ;
	}

}
